<include file="Public/header" />


<!-- 内容页 -->
<div>


    <!-- 内容 -->
    <section class="content"><div class="row"><div class="col-md-12"><div class="box">
        <form action="/admin/rbac/roleAddMenu/id/{$id}" method="post">
        <div class="box-header">
            <h3 class="box-title"></h3>


        </div>
        <!-- /.box-header -->
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <tbody>
                <tr>
                    <th><input type="checkbox" class="grid-select-all"></th>
                    <th>导航菜单/菜单</th>
                </tr>
                <input type="hidden" name="id"  value="{$id}">
                <?php foreach($nav_menu as $v){ ?>
                <tr>
                    <td></td>
                    <td>
                        {$v['name']}
                        <?php
                         foreach($menu as $m){
                            if ($v['id'] == $m['nav_menu_id']){
                    ?>
                            <tr>

                    <td><input type="checkbox" name="name[]"
                        <?php
                    foreach($role_menu as $r){
                        if ($r['menu_id'] == $m['id'] ){
                        echo 'checked';
                        }
                    }
                ?> class="grid-item" value="{$m['id']}"></td>

                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|----<?php echo $m['name'];?></td>
                            </tr>
                        <?php } } ?>
                    </td>
                </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>
        <div class="box-footer clearfix">
            <input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;

            <input type="submit" class="btn btn-sm btn-primary grid-refresh"><i class="fa fa-refresh">保存</i></input>

        </div>
    </div>
    </div>
    </div>
        </form>
    </section>
</div>
<!-- 底部 -->
</div>
<!-- jQuery 2.2.3 -->
<script src="/Public/admin/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/Public/admin/adminlte/bootstrap/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="/Public/admin/adminlte/dist/js/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/Public/admin/adminlte/dist/js/demo.js"></script>
<script src="/Public/admin/adminlte/plugins/iCheck/icheck.min.js"></script>
</body>
</html>

<script data-exec-on-popstate>

    $(function () {

        $('.grid-select-all').change(function() {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.batch-delete').on('click', function() {
            var selected = [];
            $('.grid-item:checked').each(function(){
                selected.push($(this).data('id'));
            });

            if (selected.length == 0) {
                return;
            }

            if(confirm("Are you sure to delete this item ?")) {
                $.post('/admin/auth/roles/' + selected.join(), {_method:'delete','_token':'ALpaP7hXZ6s2dnAdE02Z6mUSHPt8RkYbcDRp6rpw'}, function(data){
                    $.pjax.reload('#pjax-container');
                    noty({
                        text: "<strong>Succeeded!</strong>",
                        type:'success',
                        timeout: 1000
                    });
                });
            }
        });
    });
</script>

